package com.ht.medicaltreatment.adapter

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.bean.SghyMarshall

class GroupOrderAdapter:BaseQuickAdapter<SghyMarshall,BaseViewHolder>(R.layout.item_group_check_layout) {
    init {
        addChildClickViewIds(R.id.tvName,R.id.imgRight)
    }
    override fun convert(holder: BaseViewHolder, item: SghyMarshall) {
        holder.setText(R.id.tvName,item.rfidSampleList[0].name)
        //核验时间
        val tvCheckTime = holder.getView<TextView>(R.id.tvCheckTime)
        //分装时间
        val tvFenZhuangTime = holder.getView<TextView>(R.id.tvRecordTime)
        val checkTime = item.checkTime
        val fenZhuangTime = item.centrifugalTime
        //checkSuccess  0:未核验; 1:已核验; 2:紧急跳过
        when(item.checkSuccess){
            0 -> {
                tvCheckTime.setBackgroundResource(R.drawable.icon_group_wsb)
                tvCheckTime.setText("")
            }
            1 -> {
                tvCheckTime.setText(checkTime)
                tvCheckTime.setBackgroundColor(Color.WHITE)
                tvCheckTime.setTextColor(context.getColor(R.color.green))
            }
            2 -> {
                tvCheckTime.setBackgroundResource(R.drawable.icon_group_tg)
                tvCheckTime.setText("")
            }
        }

        if(fenZhuangTime == null && item.checkSuccess == 0){
            tvFenZhuangTime.setText("")
            tvFenZhuangTime.setBackgroundResource(R.drawable.icon_group_jilu_gray)
        }else if (fenZhuangTime == null && item.checkSuccess == 1){
            tvFenZhuangTime.setText("")
            tvFenZhuangTime.setBackgroundResource(R.drawable.icon_group_jilu_green)
        }else{
            tvFenZhuangTime.setText(fenZhuangTime)
            tvFenZhuangTime.setBackgroundColor(Color.WHITE)
            tvFenZhuangTime.setTextColor(context.getColor(R.color.green))
        }
    }
}
